package vaadin.lab6;

import com.vaadin.data.validator.AbstractValidator;

@SuppressWarnings("serial")
class CurrencyValidator extends AbstractValidator {

    public CurrencyValidator(String errorMessage) {
        super(errorMessage);
    }

    @Override
    public boolean isValid(Object value) {
        if (value instanceof String) {
            try {
                Double.parseDouble(CurrencyPropertyFormatter
                        .removeCurrencySymbols((String) value));
            } catch (NumberFormatException e) {
                return false;
            }
            return true;
        }
        return false;
    }
}